feat: integrate Hyperliquid builder fee wallet address overrides#41356
feat: integrate Hyperliquid builder fee wallet address overrides#41356abretonc7s wants to merge 38 commits intomainfrom
Conversation
Add MM_PERPS_HL_BUILDER_ADDRESS_MAINNET and MM_PERPS_HL_BUILDER_ADDRESS_TESTNET env vars so the extension can override the default builder fee wallet addresses from @metamask/perps-controller. Bump perps-controller to v2.0.0 which exposes the clientConfig.providerCredentials.hyperliquid override API.
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
✨ Files requiring CODEOWNER review ✨👨🔧 @MetaMask/extension-platform (2 files, +0 -116)
🕵️ @MetaMask/extension-privacy-reviewers (1 files, +4 -7)
👨🔧 @MetaMask/perps (2 files, +9 -1)
📜 @MetaMask/policy-reviewers (8 files, +4 -8)
Tip Follow the policy review process outlined in the LavaMoat Policy Review Process doc before expecting an approval from Policy Reviewers. 🧪 @MetaMask/qa (1 files, +4 -7)
👨🔧 @itsyoboieltr (2 files, +0 -116)
|
…rage Replace no-op tracer stubs with real Sentry delegation via globalThis.sentry (startSpanManual, setMeasurement, addBreadcrumb). Gracefully no-ops when Sentry is unavailable. Add 17 new tests covering logger, metrics, performance, tracer (with/without Sentry), and streamManager.
Move Sentry integration (pendingSpans, globalThis.sentry delegation, expanded test coverage) to a follow-up PR. Keep only the addBreadcrumb stub needed for perps-controller v2.0.0 type compatibility.
4c34c70
Switch to @metamask-previews/perps-controller@2.0.0-preview-dff83af4c (from core PR #8424) which properly excludes MYX SDK from the bundle, addressing the review concern about MYX code being included.
Automated pr-complete run — #41356
|
Builds ready [c4e788b]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 12 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
The preview build properly excludes MYX SDK, so remove: - webpack IgnorePlugin for MYXProvider.mjs - ignoreWarnings entry for MYXProvider - regenerate LavaMoat policies (removes ~640 lines of MYX policy)
…ridge (#8424) ## Explanation When `@metamask/perps-controller` v2.0.0 is consumed by the MetaMask extension, webpack throws a hard `MODULE_NOT_FOUND` error on the MYXProvider dynamic import. **Root cause:** `ts-bridge`'s `getDynamicImportExtensionTransformer` creates new AST nodes (`factory.createStringLiteral`) that discard leading comments from the original source. The `/* webpackIgnore: true */` magic comment added in #8398 is present in TypeScript source but stripped from the compiled `.mjs`/`.cjs` output. **Fix:** Extract the import path into a local variable. `ts-bridge` only transforms string literal arguments in `import()` calls, so a variable reference is left untouched — preserving both the magic comment and the original path. This avoids needing post-build scripts or build system modifications (which would violate monorepo yarn constraints). **Long-term:** The proper fix is upstream in `@ts-bridge/cli` — the transformer should copy leading comments from original nodes to synthesized ones via `ts.setSyntheticLeadingComments()`. Once that's fixed, this workaround can be reverted. ## References - Fixes the webpack error in MetaMask/metamask-extension#41356 - Follow-up to #8398 ## Changelog ### `@metamask/perps-controller` #### Fixed - Preserve `/* webpackIgnore: true */` magic comment in built dist files by using a variable for the MYXProvider dynamic import path, preventing ts-bridge from rewriting the AST node and stripping the comment ## Checklist - [x] I've updated the changelog - [x] I've verified the fix: `dist/PerpsController.mjs` and `dist/PerpsController.cjs` both contain `/* webpackIgnore: true */` - [x] Tests pass - [x] Changelog validates - [x] Yarn constraints pass <!-- CURSOR_SUMMARY --> --- > [!NOTE] > **Low Risk** > Low risk change limited to how `MYXProvider` is dynamically imported and documented in the changelog. Main risk is unintended bundler behavior if the import path variable affects tree-shaking/code-splitting in consuming builds. > > **Overview** > Ensures the `MYXProvider` dynamic import retains the `/* webpackIgnore: true */` magic comment in compiled output by moving the import specifier to a `myxModulePath` variable, avoiding `ts-bridge` rewriting that strips the comment. > > Updates the perps-controller changelog to document this fix. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit dff83af. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
Builds ready [baf2508]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 12 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [9e62ec0]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 12 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [1bd6495]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 12 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [4929c28]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 12 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [45ecbb1]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 12 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
…state keys - Remove platform-specific `resolver-binding-darwin-arm64` from LavaMoat build-system policy (CI runs on linux-x64) - Add `lastCompletedWithdrawalTimestamp` and `lastCompletedWithdrawalTxHashes` to state-logs.json (new fields in perps-controller v3.0.0)
|
Builds ready [0195659]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 12 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
aganglada
left a comment
There was a problem hiding this comment.
LGTM, have we set the new env variables



Description
The
@metamask/perps-controllerpackage has hardcoded default builder wallet addresses. The extension needs its own builder fee wallet address (0xea2c82b5aba243ab631c0ce151763d5e38df75b3) different from the package defaults.This PR adds
MM_PERPS_HL_BUILDER_ADDRESS_MAINNETandMM_PERPS_HL_BUILDER_ADDRESS_TESTNETenv vars so the extension can override builder fee wallet addresses viaclientConfig.providerCredentials.hyperliquid. Bumps@metamask/perps-controllerto stable v3.0.0, which properly excludes MYX SDK from the package (no preview build or webpack workarounds needed).Mirrors the mobile implementation from PR #27899.
Why the extra changes (v3.0.0 upgrade consequences)
The v3.0.0 bump of
@metamask/perps-controlleris a major upgrade and forces a few cascading changes in this PR. None of them are new features — they're all consequences of adopting the new package version:yarn lavamoat:auto. v3.0.0 cleanly excludes MYX SDK from the dependency graph, keeping the policy diff minimal. The browserify policy churn (~500 lines per file) is from merges with main (trezor adapter, tempo transactions, etc.), not from perps-controller changes.ui/selectors/perps-controller.ts) — v2.0.0+ replaces flat cache keys (cachedMarketData,cachedAccountState, etc.) with provider-keyed maps (cachedMarketDataByProvider,cachedUserDataByProvider). Selectors now read viaselectPerpsActiveProvider(state).errors-after-init-opt-in-ui-state.json,state-logs.json) — state snapshot tests compare actual controller state against JSON fixtures, so they had to be updated to the v2+ shape. New v3.0.0 fields:lastCompletedWithdrawalTimestamp,lastCompletedWithdrawalTxHashes.perps-controller-init.test.ts) —getDefaultPerpsControllerStatemock updated to match v2+ shape for consistency with the rest of the migration.@metamask/perps-controller@3.0.0is now a stable release on npm. The previous@metamask-previewsresolution and webpackIgnorePluginworkaround for MYX are no longer needed.Changelog
CHANGELOG entry: null
Related issues
Fixes: https://consensyssoftware.atlassian.net/browse/TAT-2397
Manual testing steps
PERPS_ENABLED=trueandMM_PERPS_HL_BUILDER_ADDRESS_MAINNET=0xea2c82b5aba243ab631c0ce151763d5e38df75b3in.metamaskrcyarn dist)clientConfig.providerCredentials.hyperliquidScreenshots/Recordings
N/A — configuration-only change, no UI impact.
Before
N/A
After
N/A
Pre-merge author checklist
Pre-merge reviewer checklist